define(['jquery'],()=>{
    class Base{
        constructor(){
            this.init()
        }
        init(){
            $('header').load('/html/header.html')
            $('footer').load('/html/footer.html')
        }
    }
    class Count{
        constructor(){
            this.init()
        }
        init(){
            this.load()
        }
        load(){
            $('header').load('/html/header.html',()=>{
                let shopspan = document.querySelector('.shopspan')
                let list = JSON.parse(localStorage.getItem('cart')) || []
                let num = 0
                list.forEach(item=>{
                    num += item.cart_number - 0
                })
                shopspan.innerHTML = num
            })
            $('footer').load('/html/footer.html')
        }
    }
    return {
        Base : new Base(),
        Count : new Count()
    }
})

// $('header').load('/html/header.html',()=>{
//     let shopspan = document.querySelector('.shopspan')
//     let list = JSON.parse(localStorage.getItem('cart')) || []
//     let num = 0
//     list.forEach(item=>{
//         num += item.cart_number - 0
//     })
//     shopspan.innerHTML = num
// })
// $('footer').load('/html/footer.html')